<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <?php include 'inc/head.php'; ?>
</head>

<body>
  <?php include 'inc/header.php'; ?>

  <div class="container">

    <table class="table table-sm table-bordered table-hover">
      <thead class="bg-light">
        <tr>
          <th>属于</th>
          <th>幻灯图片</th>
          <th>幻灯名称</th>
          <th>链接地址</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <?php
        foreach ($list as $key => $row) {
          echo '<tr><td>' . slide_parent($row['s_parent']) . '</td><td><a href="' . $row['s_picture'] . '" target="_blank"><img src="' . $row['s_picture'] . '" width="100" height="30" /></a></td><td>' . $row['s_name'] . '</td><td>' . $row['s_link'] . '</td><td><a href="' . M('admin', 'slideshow', 'edit', $key) . '">编辑</a> <a href="' . M('admin', 'slideshow', 'del', $key) . '" onclick="return confirm(\'确认要删除吗？\')">删除</a></td></tr>';
        }
        ?>
      </tbody>
    </table>

    <?php
    echo form_create(
      ['action' => M('admin', 'slideshow', 'add')],
      [
        ['type' => 'text', 'label' => '名称', 'key' => 's_name', 'required' => 'required'],
        [
          'type' => 'select', 'label' => '属于', 'key' => 's_parent', 'value' => '<option value="global">全局</option> <option value="mobile">手机端</option> <option value="index">首页</option> ' . channel_select_list(0, 0), 'html' => true
        ],
        ['type' => 'upload_img', 'label' => '图片', 'key' => 's_picture', 'required' => 'required'],
        ['type' => 'text', 'label' => '链接地址', 'key' => 's_link', 'value' => 'http://'],
        ['type' => 'text', 'label' => '排序', 'key' => 's_order', 'value' => 100, 'required' => 'required'],
        ['type' => 'submit', 'label' => '提交']
      ],
      ['幻灯新增']
    );
    ?>

  </div>

  <?php include 'inc/footer.php'; ?>

</body>

</html>